<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
   
  <meta name="keywords" content="郑浩枫,周芳怡,咸鱼郑某的博客" />
   
  <meta name="description" content="咸鱼郑某的博客" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    SQL |  岛
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/css/main.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

  

<link rel="alternate" href="/atom.xml" title="岛" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="post-SQL基础" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  SQL
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/Python-%E5%9F%BA%E7%A1%80/" class="article-date">
  <time datetime="2020-07-21T07:58:10.000Z" itemprop="datePublished">2020-07-21</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/Python/">Python</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">651字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">2分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <h2 id="SQL"><a href="#SQL" class="headerlink" title="SQL"></a>SQL</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql">USE test;<br><span class="hljs-keyword">CREATE</span>  <span class="hljs-keyword">TABLE</span>  customer <span class="hljs-keyword">LIKE</span> companysales.customer;<br></code></pre></td></tr></table></figure>

<p>在<code>test</code>表中拷贝<code>companysales</code>数据库中的<code>customer</code>表（不拷贝数据）</p>
<span id="more"></span>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql">USE test;<br><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> customer2 <span class="hljs-keyword">SELECT</span> <span class="hljs-operator">*</span> <span class="hljs-keyword">FROM</span> companysales.customer;<br></code></pre></td></tr></table></figure>

<p>在<code>test</code>表中创建<code>companysales</code>数据库中<code>customer</code>表的副本</p>
<h3 id="DESCRIBE"><a href="#DESCRIBE" class="headerlink" title="DESCRIBE"></a>DESCRIBE</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">DESCRIBE</span> customer;<br></code></pre></td></tr></table></figure>



<p>查看<code>customer</code>表结构</p>
<h3 id="show-create-table"><a href="#show-create-table" class="headerlink" title="show create table"></a>show create table</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SHOW</span> <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> customer;<br></code></pre></td></tr></table></figure>

<p>展示<code>customer</code>的表结构</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> employee(employeename,sex,birthdate,hiredate,salary,departmentid)<br><span class="hljs-keyword">VALUE</span>(<span class="hljs-string">&#x27;你妈&#x27;</span>,<span class="hljs-string">&#x27;女&#x27;</span>,<span class="hljs-string">&#x27;1980-2-1&#x27;</span>,<span class="hljs-string">&#x27;2016-8-9&#x27;</span>,<span class="hljs-number">3400</span>,<span class="hljs-number">1</span>)<br></code></pre></td></tr></table></figure>

<p>插入行</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">UPDATE employee <span class="hljs-keyword">SET</span> salary <span class="hljs-operator">=</span> salary <span class="hljs-operator">*</span> <span class="hljs-number">10</span>;<br></code></pre></td></tr></table></figure>

<p>更新表数据</p>
<h3 id="PRIMARY-KEY-KEY1-KEY2"><a href="#PRIMARY-KEY-KEY1-KEY2" class="headerlink" title="PRIMARY KEY(KEY1,KEY2)"></a>PRIMARY KEY(KEY1,KEY2)</h3><p>组合主键</p>
<h3 id="删除主键"><a href="#删除主键" class="headerlink" title="删除主键"></a>删除主键</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs SQL"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> table_name<br><br><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">PRIMARY</span> KEY<br></code></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs plain">ALTER TABLE borrow<br>ADD CONSTRAINT pk_key PRIMARY KEY(bookid, borrowerid);<br></code></pre></td></tr></table></figure>



<h3 id="添加主键"><a href="#添加主键" class="headerlink" title="添加主键"></a>添加主键</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> table_name<br> <span class="hljs-keyword">ADD</span> <span class="hljs-keyword">PRIMARY</span> KEY(KEY)<br></code></pre></td></tr></table></figure>





<h3 id="复制表"><a href="#复制表" class="headerlink" title="复制表"></a>复制表</h3><p> CREATE TABLE aaa SELECT * FROM companysales.<code>department</code></p>
<p>复制过来后，主键和自增都没有了</p>
<h3 id="外键"><a href="#外键" class="headerlink" title="外键"></a>外键</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-comment">--1，sql语句创建表的同时添加外键约束</span><br><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> tb_UserAndRole  <span class="hljs-comment">--用户角色表</span><br>(<br>  ID <span class="hljs-type">INT</span> <span class="hljs-keyword">PRIMARY</span> KEY <span class="hljs-keyword">IDENTITY</span>(<span class="hljs-number">1</span>,<span class="hljs-number">1</span>),<br>  UserID <span class="hljs-type">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span>,<span class="hljs-comment">--用户ID</span><br>  RoleID <span class="hljs-type">INT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span>,<span class="hljs-comment">--角色ID</span><br>  <span class="hljs-keyword">foreign</span> key(UserID) <span class="hljs-keyword">references</span> tb_Users(ID)<span class="hljs-comment">--tb_Users表的ID作为tb_UserAndRole表的外键</span><br>)<br> <br>   <span class="hljs-comment">--2、添加外键约束(关联字段要用括号括起来)</span><br>   <span class="hljs-comment">-- ALTER TABLE 从表</span><br>   <span class="hljs-comment">-- ADD CONSTRAINT 约束名 FOREIGN KEY (关联字段) references 主表(关联字段);</span><br>   <span class="hljs-comment">--例如：</span><br>　　<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> tb_UserAndRole<br>   <span class="hljs-keyword">ADD</span> <span class="hljs-keyword">CONSTRAINT</span> FK__tb_UandR_Role <span class="hljs-keyword">FOREIGN</span> KEY (RoleID) <span class="hljs-keyword">references</span> tb_Role(ID);<br></code></pre></td></tr></table></figure>



<p>删除外键 </p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> Orders<br><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">FOREIGN</span> KEY fk_PerOrders<br></code></pre></td></tr></table></figure>



<h3 id="SQL-去除重复行-DISTINCT"><a href="#SQL-去除重复行-DISTINCT" class="headerlink" title="SQL 去除重复行 DISTINCT"></a>SQL 去除重复行 DISTINCT</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">DISTINCT</span> departmentid <span class="hljs-keyword">FROM</span> employee<br></code></pre></td></tr></table></figure>



<h3 id="SQL指定查询的列名"><a href="#SQL指定查询的列名" class="headerlink" title="SQL指定查询的列名"></a>SQL指定查询的列名</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SELECT</span> employeename 员工姓名,sex 员工性别 <span class="hljs-keyword">FROM</span> employee;<br></code></pre></td></tr></table></figure>

<p>或</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SELECT</span> employeename <span class="hljs-keyword">AS</span> 员工姓名,sex  <span class="hljs-keyword">AS</span> 员工性别 <span class="hljs-keyword">FROM</span> employee;<br></code></pre></td></tr></table></figure>



<h3 id="NOW"><a href="#NOW" class="headerlink" title="NOW()"></a>NOW()</h3><p>获取当前时间的函数</p>
<h3 id="范围-BETWEEN-···-AND"><a href="#范围-BETWEEN-···-AND" class="headerlink" title="范围 BETWEEN ···  AND"></a>范围 BETWEEN ···  AND</h3><h3 id="列表-IN-NOT-IN"><a href="#列表-IN-NOT-IN" class="headerlink" title="列表 IN , NOT IN"></a>列表 IN , NOT IN</h3><h3 id="字符串-LIKE-NOT-LIKE"><a href="#字符串-LIKE-NOT-LIKE" class="headerlink" title="字符串 LIKE , NOT LIKE"></a>字符串 LIKE , NOT LIKE</h3><h3 id="空-IS-NULL-IS-NOT-NULL"><a href="#空-IS-NULL-IS-NOT-NULL" class="headerlink" title="空  IS NULL , IS NOT NULL"></a>空  IS NULL , IS NOT NULL</h3><h3 id="逻辑-AND-OR-NOT"><a href="#逻辑-AND-OR-NOT" class="headerlink" title="逻辑 AND OR NOT"></a>逻辑 AND OR NOT</h3><h3 id="IN-NOT-IN"><a href="#IN-NOT-IN" class="headerlink" title="IN , NOT IN"></a>IN , NOT IN</h3><p>查询员工工资是3000,5000,7000的</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SELECT</span> employeename <span class="hljs-keyword">AS</span> 员工姓名,salary  <span class="hljs-keyword">AS</span> 员工工资 <span class="hljs-keyword">FROM</span> employee<br><span class="hljs-keyword">WHERE</span> salary <span class="hljs-keyword">IN</span>(<span class="hljs-number">3000</span>,<span class="hljs-number">5000</span>,<span class="hljs-number">7000</span>)<br></code></pre></td></tr></table></figure>



<h3 id="多分组"><a href="#多分组" class="headerlink" title="多分组"></a>多分组</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span> A,B<br></code></pre></td></tr></table></figure>



<h3 id="GROUP-CONCAT"><a href="#GROUP-CONCAT" class="headerlink" title="GROUP_CONCAT"></a>GROUP_CONCAT</h3><h3 id="LIMIT"><a href="#LIMIT" class="headerlink" title="LIMIT"></a>LIMIT</h3><h3 id="SQL联接"><a href="#SQL联接" class="headerlink" title="SQL联接"></a>SQL联接</h3><h4 id="交叉联接-CROSS-JOIN"><a href="#交叉联接-CROSS-JOIN" class="headerlink" title="交叉联接 CROSS JOIN"></a>交叉联接 CROSS JOIN</h4><p>表A的每个字段和表B的每个字段相联接 </p>
<h4 id="INNER-JOIN"><a href="#INNER-JOIN" class="headerlink" title="INNER JOIN"></a>INNER JOIN</h4><p>NNER JOIN 关键字在表中存在至少一个匹配时返回行。</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs SQL"><span class="hljs-keyword">SELECT</span> column_name(s)<br><span class="hljs-keyword">FROM</span> table1<br><span class="hljs-keyword">INNER</span> <span class="hljs-keyword">JOIN</span> table2<br><span class="hljs-keyword">ON</span> table1.column_name<span class="hljs-operator">=</span>table2.column_name;<br></code></pre></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs sql">##查询员工“孔高铁”的销售业绩，包括商品名称、数量、金额。<br><span class="hljs-keyword">SELECT</span> productname 商品名称,<span class="hljs-built_in">SUM</span>(sellordernumber) 数量 ,price ,<span class="hljs-built_in">SUM</span>(price<span class="hljs-operator">*</span>sellordernumber) <span class="hljs-keyword">AS</span> 金额 <span class="hljs-keyword">FROM</span> `employee` <br><span class="hljs-keyword">JOIN</span> `sell_order` <span class="hljs-keyword">ON</span> `employee`.employeeid <span class="hljs-operator">=</span> `sell_order`.employeeid <span class="hljs-keyword">AND</span> `employee`.employeeid <span class="hljs-operator">=</span> <span class="hljs-number">6</span><br><span class="hljs-keyword">JOIN</span> `product` <span class="hljs-keyword">ON</span> sell_order.productid <span class="hljs-operator">=</span> `product`.productid <br><span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span> `product`.productid <span class="hljs-keyword">WITH</span> <span class="hljs-keyword">ROLLUP</span><br></code></pre></td></tr></table></figure>



<p>ON  链接条件</p>
<p><strong>on</strong> 条件是在生成临时表时使用的条件，它不管 <strong>on</strong> 中的条件是否为真，都会返回左边表中的记录。</p>
<h4 id="WITH-ROLLUP"><a href="#WITH-ROLLUP" class="headerlink" title="WITH ROLLUP"></a>WITH ROLLUP</h4><p>跟在GROUP BY 后面，用于汇总上面的所有数据</p>
<h3 id="在临时表中添加一列自增字段"><a href="#在临时表中添加一列自增字段" class="headerlink" title="在临时表中添加一列自增字段"></a>在临时表中添加一列自增字段</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">SELECT</span>  <span class="hljs-variable">@rownum</span>:<span class="hljs-operator">=</span><span class="hljs-variable">@rownum</span><span class="hljs-operator">+</span><span class="hljs-number">1</span> <span class="hljs-keyword">as</span> <span class="hljs-string">&#x27;index&#x27;</span>,organization,img_name <span class="hljs-keyword">FROM</span>  (<span class="hljs-keyword">select</span> <span class="hljs-variable">@rownum</span>:<span class="hljs-operator">=</span><span class="hljs-number">0</span>)t,all_img<br></code></pre></td></tr></table></figure>

<p>贼屌这个，要记住，from中一定要加<code>(select @rownum:=0)t</code></p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        打赏
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>版权声明： </strong s>
              本博客所有文章除特别声明外，均采用 <a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="external nofollow"
                target="_blank">Apache License 2.0</a> 许可协议。转载请注明出处！
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://zhfhz.gitee.io/2020/Python-%E5%9F%BA%E7%A1%80/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%BC%96%E7%A8%8B/" rel="tag">编程</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/Python-%E5%9F%BA%E7%A1%80/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Python-基础
          
        </div>
      </a>
    
    
      <a href="/2020/%E5%A4%A7%E5%B8%88%E6%91%84%E5%BD%B1%E4%BD%9C%E5%93%81%E5%88%86%E4%BA%AB/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">大师摄影作品分享</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'QExPaN3yEdYGXDLijnPKdTc8-MdYXbMMI',
        app_key: 'kyQzz6yRJkdRHcMm0tpOvSYY',
        path: window.location.pathname,
        notify: 'true',
        verify: 'false',
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020-2021
        ZHF
      </li>
      <li>
        
        Powered by
        
        
        <a href="https://hexo.io" target="_blank">Hexo</a> Theme <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src=''></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
    <aside class="sidebar">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="岛"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="https://500px.me/ZHFHZ">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/share.js"></script>


<script src="/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/js/ayer.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>




<script src="/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

    
  </div>
</body>

</html>